import random

my_list = []
for i in range(1, 101):
    if i % 2 == 0:
        my_list.append(i)
print(my_list)

for i in range(len(my_list)):
    my_list[i] = my_list[i] * my_list[i]

new = []
for i in my_list:
    if i < 1000:
        new.append(i)
print(new)

my_list.reverse()

my_list.extend([101, 102, 103])
sum = 0
for i in my_list:
    sum += i
avg = sum / len(my_list)
print(avg)

my_list.sort()
print(my_list)
max = my_list[-1]
min = my_list[0]
print(max, min)

# print(my_list.index(11))
# for i in range(len(my_list)):
#     if type(my_list[i]) is int:
#         my_list[i] = str(my_list[i])
# print(my_list)

for i in range(len(my_list)):
    if type(my_list[i]) is int:
        my_list[i] = float(my_list[i])
print(my_list)
new = []
for i in range(len(my_list)):
    if my_list[i] > 50:
        new.append(my_list[i])
print(new)

my_list.insert(2, 99)
print(my_list)

my_list.pop(-1)
print(my_list)

new_list = [2 * my_list[i] for i in range(len(my_list))]
print(new_list)

l1 = []
l2 = []
for i in range(len(my_list)):
    if my_list[i] <= 50:
        l1.append(my_list[i])
    elif my_list[i] > 50:
        l2.append(my_list[i])
print(l1, l2)

my_dict = {values: key for key, values in enumerate(my_list)}
print(my_dict)

for i in enumerate(my_list):
    print(i)

rand = random.choice(my_list)
print(rand)

with open('file1.txt', 'w') as file:
    for i in my_list:
        file.write(str(i) + '\n')
